package com.quxueba.index.controller;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.quxueba.index.dal.AppDao;
import com.quxueba.index.model.Product;
import com.quxueba.index.model.School;
import com.quxueba.index.model.User;

@Controller
@RequestMapping("/")
public class IndexController {
	
//	@Autowired @Qualifier("sessionFactory")
//	@Autowired
//	@Qualifier("sessionFactory")
//	@Resource
//	public SessionFactory sessionFactory;
//	public Session session = sessionFactory.getCurrentSession();
	
	@Autowired
	public AppDao appDao;
	
	@RequestMapping(value = "a", method = RequestMethod.GET)
    @ResponseBody
//    public String a() {
    public List<User> a() {
		System.out.println("session");
		List<User> list = appDao.ff();
		System.out.println(JSON.toJSONString(list));
//		return JSON.toJSONString(list);
//		return list.toString();
		return list;
//		return "9999999999";
	}
	
	@RequestMapping(value = "b", method = RequestMethod.GET)
    @ResponseBody
    public List<School> b() {
		System.out.println("session");
		List<School> list = appDao.getSchool();
		System.out.println(JSON.toJSONString(list));
//		return JSON.toJSONString(list);
//		return list.toString();
		return list;
//		return "9999999999";
	}
	
	@RequestMapping(value = "p", method = RequestMethod.GET)
    @ResponseBody
    public List<Product> p() {
		return appDao.getProduct();
	}
}
